/*
 * Copyright 2014, NuzoweR@Schneefeuer <nuzower@gmail.com>.
 * The Settlers Online - Combat Simulator (tsosim).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef SIMPARSER_H_
#define SIMPARSER_H_

#include <string>
#include <list>

class Unit;
class Garrison;
class Simulator;

class SimParser
{
public:

	enum Mode { MODE_NORMAL, MODE_UNIT, MODE_GARRISON, MODE_SIM };

	bool process_file(std::string const& path);

	SimParser();

private:

	bool process_import(std::string const& LINE, int start_pos, int line_number);

	bool process_unit    (std::string const& LINE, int start_pos, int line_number, std::string const& filename);
	bool process_garrison(std::string const& LINE, int start_pos, int line_number, std::string const& filename);
	bool process_sim     (std::string const& LINE, int start_pos, int line_number, std::string const& filename);

	void set_current_sim(Simulator* sim);

	struct Current {
		Current() : unit(NULL), garrison(NULL), sim(NULL), unit_new(true) {};
		Unit*	    unit;
		Garrison*   garrison;
		Simulator*  sim;
		bool        unit_new;
	} CURRENT;

	std::list<std::string> path_stack;
};

#endif // SIMPARSER_H_
